home *** CD-ROM | disk | FTP | other *** search
/ Point Programming 1 / PPROG1.ISO / pascal / swag / printing.swg / 0044_Complete PRINTER Unit.pas < prev   
Encoding:
Pascal/Delphi Source File  |  1995-02-28  |  1.2 KB  |  51 lines

  1.  
  2. unit Prt;
  3. interface
  4. uses objects;
  5. const
  6. Lpt1=  0; Lpt2=  1;
  7. Lpt3=  2; lf = #10;
  8. cr = #13; pTimeOut= $01;
  9. pIOError= $08; pNoPaper= $20;
  10. pNotBusy= $80;
  11. pTestAll= pTimeOut + pIOError + pNoPaper;
  12. function WriteChar(const APort : word; s : char): boolean;
  13. function Ready(const APort : word): boolean;
  14. function Status(const APort : word): byte;
  15. procedure InitPrinter(const APort : word);
  16. implementation
  17. procedure InitPrinter(const APort : word); assembler;
  18. asm
  19. mov ah, 1
  20. mov bx, APort
  21. int 17h
  22. end;
  23. function Status(const APort : word): byte; assembler;
  24. asm
  25. mov ah, 2  { Service 2 - Printer Status }
  26. mov dx, APort { Printer Port  }
  27. int 17h { ROM Printer Services  }
  28. mov al, ah { Set function value }
  29. end;
  30. function Ready(const APort : word): boolean;
  31. begin
  32. Ready := Status(APort) and pTestAll = $00;
  33. end;
  34. function WriteChar(const APort : word; s : char): boolean;
  35. begin
  36. if Ready(APort) then
  37.  asm
  38. mov ah, 0  { Printer Service - Write Char }
  39. mov al, s  { Char to write}
  40. mov dx, APort  { Printer Port }
  41. int 17h { ROM Printer Services }
  42. mov al, 0  { Set procedure to false  }
  43. and ah, 1  { Check for Error }
  44. jnz @End{ Jump to end if error }
  45. mov al, 1  { Set procedure to true}
  46.   @End:
  47. end;
  48. end;
  49.  
  50. end.
  51.